//
//  NSDate+Ext.swift
//  icar
//
//  Created by gongkai on 15/4/7.
//  Copyright (c) 2015年 anytracking. All rights reserved.
//

import Foundation

extension NSDate{
    //年
    var year:Int{
        return  NSCalendar.currentCalendar().components(.CalendarUnitYear, fromDate: self).year
    }
    //月
    var month:Int{
        return  NSCalendar.currentCalendar().components(.CalendarUnitMonth, fromDate: self).month
    }
    //天
    var day:Int{
        return  NSCalendar.currentCalendar().components(.CalendarUnitDay, fromDate: self).day
    }
    //小时
    var hour:Int{
        return  NSCalendar.currentCalendar().components(.CalendarUnitHour, fromDate: self).hour
    }
    //分
    var minute:Int{
        return  NSCalendar.currentCalendar().components(.CalendarUnitMinute, fromDate: self).minute
    }
    //秒
    var second:Int{
        return  NSCalendar.currentCalendar().components(.CalendarUnitSecond, fromDate: self).second
    }
    //星期几
    var weekday:Int{
        return  NSCalendar.currentCalendar().components(.CalendarUnitWeekday, fromDate: self).weekday
    }
}